/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nanterre.annuaire.bd;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author illamhat
 */

public class Oracle  {
    private Connection conn;
    
    public Oracle(){
        super();
    }
    
    public void logIn() {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            this.conn = DriverManager.getConnection("jdbc:oracle:thin:@172.19.255.3:1521:MIAGE", "lmd4", "mylmd414");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Oracle.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Oracle.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void logOut(){
        try {
            this.conn.close();      
       
        } catch (SQLException ex) 
        {
            Logger.getLogger(Oracle.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public ResultSet doSelectRequest(String requete){
        Statement stm;
        ResultSet rs = null;
        try {
            stm = this.conn.createStatement();
            rs = stm.executeQuery(requete);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            Logger.getLogger(BDInteraction.class.getName()).log(Level.SEVERE, null, e);
        }
        return rs;
    }
    
    
    

	public Connection getConn() {
		return conn;
	}

	public void setConn(Connection conn) {
		this.conn = conn;
	}
    
    
}
